//引入模块
var ImageLoader = require('util/imageloader.jsx');
var routes = require('router/router.jsx');
var conf = require('conf.jsx');
var BANNER_NUM = conf.BANNER_NUM;
var ITEM_NUM = conf.ITEM_NUM;
var processDOM = $('#app .loader-text span');

//异步请求加载数据
$.get('data/sites.json',function (res) {
    // console.log(res);
    // 请求成功保存数据
    if(res && res.errno ===0){
        conf.DATABASE = res.data;
        //加载图片
        new ImageLoader({
            bannerNum:BANNER_NUM,
            itemNum:ITEM_NUM
        },function (num, total) {
            //每加载一张图片更新内容*100% 保留两位小数
            processDOM.html((num/total*100).toFixed(2))
        },function () {
            //成功时候，将元素删除
            processDOM.html('100.00');
            // setTimeout(function () {
            ReactDOM.render(routes,document.getElementById('app'));
            // },1000)
        },function (num, total) {
            console.log("fail",num,total)
        })
    }
})